package com.dailyblue.project.smbms.alibaba.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dailyblue.project.smbms.alibaba.commons.bean.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserMapper extends BaseMapper<User> {
    @Select("select u.*,if(gender=1,'女','男') as 'userSex',floor(datediff(now(),birthday)/365) as 'userAge' from smbms_user u where userstate=1")
    List<User> find();

    @Select("select u.*,if(gender=1,'女','男') as 'userSex',floor(datediff(now(),birthday)/365) as 'userAge' from smbms_user u where userstate=1 and userName like #{name}")
    List<User> findByUserName(String name);
    @Update("update smbms_user set userpassword=md5(#{password}) where id=#{id}")
    int updateUserPassword(@Param("id") int id,@Param("password") String password);
}
